import { defineStore } from 'pinia'
import { getUserMenu } from '@api/user'
import { useUserStore } from '@store/useUserStore'
import { Parent } from '@interface/user'
export const useMenuStore = defineStore('menuId', {
  state: ():{
    menu:Parent[]
  }=> {
    return {
      menu:[]
    }
  },
  getters:{},
  actions:{
    async getMenu(){
      console.log('获取菜单');
      
        let res = await getUserMenu(useUserStore().rolePerm);
        this.menu = res.data;
        console.log('菜单',useUserStore().rolePerm,res  );
    }
  },
  persist: {
    enabled: true, //开启数据缓存
    strategies: [
      {
        storage: localStorage,//默认走session
        paths: ['menu']
      }
    ]
  }
})